package o10gettargertnumber;

/**
 * @author shkstart
 * @create 2022-01-05-18:39
 */
public class GetTargetNumberIndex {

    public static void main(String[] args) {
        int[] nums = {1,3,5,6};
        searchInsert(nums,2);
    }


    public static int searchInsert(int[] nums, int target) {
        int sign = 0;

        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == target) {
                return i;
            }
            else if (nums[i] < target) {
                sign = i + 1;
            }
            else {
                break;
            }
        }


        return sign;
    }

}
